package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter
@Getter
@JsonIgnoreProperties("handler")
public class StrategyCatalog extends  BaseDomain{
    public static final boolean STATE_OPEN = true; // 启用
    public static final boolean STATE_BAN = false;// 禁用

    private String name; // 名称

    private Strategy strategy;// 所属攻略

    private Integer sequence; // 序号

    private Boolean state; // 状态

    List<StrategyDetail> details = new ArrayList<>();

    //页面数据 回显
    public String getJsonString(){
        Map<String,Object> map  = new HashMap<>();
        map.put("id",getId());
        if(strategy != null){
            map.put("strategyId",strategy.getId());
        }
        map.put("name",name);
        map.put("sequence",sequence);
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }

    // 页面状态回显
    public String getStateDisplay(){
        if(state == null){
            return "";
        }
        if(state){
            return "启用";
        }else{
            return "推荐";
        }
    }


}